const defaultState = {
  newsList: [],
  toExamineList: [],
  collapsedFlag: false
}
// eslint-disable-next-line import/no-anonymous-default-export
export const DataReducer = (state = defaultState, action) => {
  console.log(123456, action)
  let newState = JSON.parse(JSON.stringify(state))
  if (action.type === 'sendNews') {
    newState.newsList.push(action.value)
    return newState
  } else if (action.type === 'delete') {
    newState.newsList.splice(action.value, 1)
    console.log(newState.newsList)
    return newState
  } else if (action.type === 'handleCheck') {
    newState.toExamineList.push(action.value)
    return newState
  } else if (action.type === 'collapsedFlag') {
    console.log('change_loading')
    newState.collapsedFlag = !newState.collapsedFlag
    return newState
  }
  return state
}